package com.huabo.audit.controller;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.hbfk.util.JsonBean;
import com.hbfk.util.ResponseFormat;
import com.huabo.audit.oracle.entity.TblNbsjRefopm;
import com.huabo.audit.oracle.entity.TblNbsjReformSolution;
import com.huabo.audit.service.TblNbsjRefopmService;
import com.huabo.audit.service.TblNbsjReformSolutionService;
import com.huabo.audit.util.ExcelUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;



/**
 * 智能审计模块拆分(审计整改)
 * @author Lenovo
 *
 */
@RestController
@Api(value = "审计整改", tags = {"整改跟踪所有接口"})
@RequestMapping(value = "/nbsjzg")
public class NbsjZgController {
	
	@Resource
	public TblNbsjReformSolutionService solutionService;
	
	@Resource
	public TblNbsjRefopmService refopmservice;
	
	
	
	@GetMapping("/getZgContentsList")
    @ApiOperation("整改方案-添加整改内容页面分页功能")
    public JsonBean getzgContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="selectidIdsstr",value="方案已关联的内容问题ID拼接串",required=false)@RequestParam(value = "selectidIdsstr", required = false) String selectidIdsstr,
   	    @ApiParam(name="projectid",value="整改方案关联项目id",required=false) @RequestParam(value = "projectid", required = false) BigDecimal projectid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.getAllReformNbsjByProject(re, pageNumber, pageSize, projectid, selectidIdsstr);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
	
	
	
	@GetMapping("/getZgsolutionmgmtList")
    @ApiOperation("整改方案列表分页功能")
    public JsonBean getAuditPlanPageList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name,
   		@ApiParam(name="createstaffid",value="创建人",required=false)@RequestParam(value = "createstaffid", required = false) Integer createstaffid,
   		@ApiParam(name="runstatus",value="状态",required=false)@RequestParam(value = "runstatus", required = false) Integer runstatus) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,"",createstaffid,runstatus);
		} catch (Exception e) {
			e.printStackTrace();
		}
        return jsonBean;
    }
	
    @GetMapping("/getSolutionDetail")
    @ApiOperation("整改方案查看详情信息")
    public JsonBean getAuditPlanInfo(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="solutionid",value="整改方案主键",required=true)@RequestParam(value = "solutionid", required = true) String solutionid) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findBySolutionid(solutionid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    
    @RequestMapping(value = "/mergeSolutionInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案新增或修改")
	public JsonBean mergePlanProjectManageInfo(HttpServletRequest request,@ApiParam(name="solution",value="整改方案实体",required=true)TblNbsjReformSolution solution,
			 @ApiParam(name="solutionid",value="整改方案主键 ，如果主键为空则根据编码新增信息",required=false) BigDecimal solutionid,
			 @ApiParam(name="endDate",value="截止时间",required=false) @RequestParam(value="endDate", required = false) String endDate,
			 @ApiParam(name="reformid",value="根据项目选择后的问题拼接id",required=false)@RequestParam(value="reformid", required = false) String reformid,
			 @ApiParam(name="attids",value="上传附件的ID",required=false) @RequestParam(value="attids", required = false) String attids,
			 @ApiParam(name="projectid",value="选择的关联项目id",required=false) @RequestParam(value="projectid", required = false)  String projectid,
			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
    	JsonBean jsonBean = null;
		try {
			if(solutionid!=null) {
				solution.setSolutionid(solutionid);
			}
			jsonBean = this.solutionService.saveOrUpdate(solution, token, reformid, attids, projectid, endDate);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
	} 
	
    
    
    @RequestMapping(value = "/getSolutionAttInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案获取所属的附件")
    public JsonBean getAuditPlanAttInfo(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="solutionid",value="整改方案主键 ",required=true)@RequestParam(value = "solutionid", required = true) Integer solutionid) {
    	JsonBean jsonBean = null;
		try {
			jsonBean = this.solutionService.getAttListBySolutionId(token,solutionid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    
    
    @RequestMapping(value = "/delSolutionAttInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案删除选择的附件")
    public JsonBean delSolutionAttInfo(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="attid",value="附件ID ",required=true)@RequestParam(value = "attid", required = true)  BigDecimal attid) {
    	JsonBean jsonBean = null;
		try {
			jsonBean = this.solutionService.delAttListBySolutionId(token,attid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    
    @RequestMapping(value = "/issuePersonliable", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案下发整改责任人")
    public JsonBean issuePersonliable(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="solutionid",value="整改方案ID ",required=true)@RequestParam(value = "solutionid", required = true) BigDecimal solutionid,
    		@ApiParam(name="reformuserid",value="选择的用户id ",required=true)@RequestParam(value = "reformuserid", required = true)  BigDecimal reformuserid) {
    	JsonBean jsonBean = null;
		try {
			TblNbsjReformSolution solution=new TblNbsjReformSolution();
			if(solutionid!=null) {
				solution.setSolutionid(solutionid);
				solution.setReformuserid(reformuserid);
			}
			jsonBean = this.solutionService.xfry(solution, token);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    
    
    @RequestMapping(value = "/startSolution", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案启动")
    public JsonBean startSolution(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="solutionid",value="整改方案ID ",required=true)@RequestParam(value = "solutionid", required = true) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
		try {
			TblNbsjReformSolution solution=new TblNbsjReformSolution();
			if(solutionid!=null) {
				solution.setSolutionid(solutionid);
				solution.setRunstatus(1);
			}
			jsonBean = this.solutionService.saveOrUpdate(solution, token, null, null, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    @RequestMapping(value = "/deleteSolution", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改方案删除")
       public JsonBean deleteSolution(HttpServletRequest request,
       		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
       		@ApiParam(name="solutionid",value="整改方案ID ",required=true)@RequestParam(value = "solutionid", required = true)BigDecimal solutionid) {
       	JsonBean jsonBean = null;
   		try {
   			
   			jsonBean = this.solutionService.delete(solutionid.toString(), token);
   		} catch (Exception e) {
   			e.printStackTrace();
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
       }
    
    @RequestMapping(value = "/closeSolution", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改方案关闭")
    public JsonBean closeSolution(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="solutionid",value="整改方案ID ",required=true)BigDecimal solutionid) {
    	JsonBean jsonBean = null;
		try {
			TblNbsjReformSolution solution=new TblNbsjReformSolution();
			if(solutionid!=null) {
				solution.setSolutionid(solutionid);
				solution.setRunstatus(3);
			}
			jsonBean = this.solutionService.saveOrUpdate(solution, token, null, null, null, null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    
    
    
    @GetMapping("/getZgfpsolutionmgmtList")
    @ApiOperation("整改分派列表分页功能")
    public JsonBean zgfpsolutionmgmtList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,"1",null,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    
    
    @GetMapping("/getfpContentsList")
    @ApiOperation("整改分派-整改内容页面分页功能")
    public JsonBean getfpContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value = "solutionid", required = false) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.findTblReformBySheetIdAndSoultionid(code, solutionid, pageNumber, pageSize, re,"1",token);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    
    
    @RequestMapping(value = "/fpSolutionRy", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改分派-分派保存人员")
	public JsonBean fpSolutionRy(@ApiParam(name="userid",value="分派的整改执行人员id",required=false)  BigDecimal userid,
			 @ApiParam(name="reformid",value="分派任务id",required=false) BigDecimal reformid,
			 @ApiParam(name="solutionid",value="方案id",required=false) BigDecimal solutionid,
			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
    	JsonBean jsonBean = null;
		try {
			TblNbsjRefopm re =new TblNbsjRefopm();
			if(reformid!=null) {
				re.setReformid(reformid);
				re.setPeronincharge(userid);
			}
			jsonBean = refopmservice.saveOrupdate(re,token,solutionid);
		} catch (Exception e) {
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
	} 
	
    
    
    
    @GetMapping("/getZggzsolutionmgmtList")
    @ApiOperation("整改跟踪列表分页功能")
    public JsonBean getZggzsolutionmgmtList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,null,null,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    
    
    @GetMapping("/getgzContentsList")
    @ApiOperation("整改跟踪-整改内容页面分页功能")
    public JsonBean getgzContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value = "solutionid", required = false) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.findTblReformBySheetIdAndSoultionid(code, solutionid, pageNumber, pageSize, re,null,token);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    @GetMapping("/getZglsSolutionmgmtList")
    @ApiOperation("整改落实列表分页功能")
    public JsonBean getZglsSolutionmgmtList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,"2",null,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    @GetMapping("/getLsContentsList")
    @ApiOperation("整改落实-整改内容页面分页功能")
    public JsonBean getLsContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value = "solutionid", required = false) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.findTblReformBySheetIdAndSoultionid(code, solutionid, pageNumber, pageSize, re,"2",token);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    @RequestMapping(value = "/getReformByid", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改落实-获取整改落实信息")
   	public JsonBean getReformByid(
   			 @ApiParam(name="reformid",value="任务id",required=false)  String reformid,
   			 @ApiParam(name="solutionid",value="方案id",required=false)  BigDecimal solutionid,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			jsonBean=refopmservice.getByid(reformid);
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
   	
    
    @RequestMapping(value = "/saveReformInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改落实-保存整改落实信息")
   	public JsonBean saveReformInfo(
   			 @ApiParam(name="reformid",value="任务id",required=false)  BigDecimal reformid,
   			 @ApiParam(name="refopm",value="整改任务实体",required=true)TblNbsjRefopm refopm,
   			 @ApiParam(name="solutionid",value="方案id",required=false)  BigDecimal solutionid,
   			 @ApiParam(name="attids",value="上传附件id拼接串",required=false) String attids,
   		     @ApiParam(name="plancomdate",value="计划完成时间",required=false)  String plancomdate,
   		     @ApiParam(name="linedate",value="整改截止时间",required=false)  String linedate,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			if(reformid!=null) {
   				refopm.setReformid(reformid);
   			}
   			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
   			if(plancomdate!=null && plancomdate.trim().length()>0) {
   				refopm.setNextmplancomdate(sdf.parse(plancomdate));
   			}
   			if(linedate!=null && linedate.trim().length()>0) {
   				refopm.setReformdeadline(sdf.parse(linedate));
   			}
   			jsonBean=refopmservice.update(refopm, token, solutionid, attids, null);
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    
    @RequestMapping(value = "/tjReform", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改落实-提交整改落实信息")
   	public JsonBean tjReform(
   			 @ApiParam(name="solutionid",value="方案id",required=false) BigDecimal solutionid,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			jsonBean=refopmservice.tjyz(solutionid, token);
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    
    
    
    @GetMapping("/getZgcxSolutionmgmtList")
    @ApiOperation("整改查询列表分页功能")
    public JsonBean getZgcxSolutionmgmtList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,null,null,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    @GetMapping("/getcxContentsList")
    @ApiOperation("整改查询-整改内容页面分页功能")
    public JsonBean getcxContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value = "solutionid", required = false) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.findTblReformBySheetIdAndSoultionid(code, solutionid, pageNumber, pageSize, re,null,token);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    
    
    
    @GetMapping("/getZgjcSolutionmgmtList")
    @ApiOperation("整改评价列表分页功能")
    public JsonBean getZgjcSolutionmgmtList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="整改方案编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="name",value="整改方案名称",required=false)@RequestParam(value = "name", required = false) String name) {
    	JsonBean jsonBean = null;
    	try {
			jsonBean = solutionService.findAllcxs(code, name, pageNumber, pageSize,token,"3",null,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    @GetMapping("/getpjContentsList")
    @ApiOperation("整改评价-整改内容页面分页功能")
    public JsonBean getpjContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code,
   		@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value = "solutionid", required = false) BigDecimal solutionid) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.findTblReformBySheetIdAndSoultionid(code, solutionid, pageNumber, pageSize, re,null,token);
		} catch (Exception e) {
			e.printStackTrace();
		}
        return jsonBean;
    }
    
    
    
    @RequestMapping(value = "/getpjReformByid", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改评价-获取整改评价信息")
   	public JsonBean getpjReformByid(
   			 @ApiParam(name="reformid",value="任务id",required=false)  String reformid,
   			 @ApiParam(name="solutionid",value="方案id",required=false)  BigDecimal solutionid,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			jsonBean = refopmservice.getByid(reformid);
   		} catch (Exception e) {
   			e.printStackTrace();
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    
    @RequestMapping(value = "/savepjReformInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改评价-保存评价信息")
   	public JsonBean savepjReformInfo(
   			 @ApiParam(name="reformid",value="任务id",required=false)  BigDecimal reformid,
   			 @ApiParam(name="refopm",value="整改评价实体",required=true)TblNbsjRefopm refopm,
   			 @ApiParam(name="solutionid",value="方案id",required=false)  BigDecimal solutionid,
   			@ApiParam(name="attids",value="上传附件id拼接串",required=false)  String attids,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			if(reformid!=null) {
   				refopm.setReformid(reformid);
   			}
   			jsonBean=refopmservice.update(refopm, token, solutionid, attids, "1");
   		} catch (Exception e) {
   			e.printStackTrace();
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    
    @RequestMapping(value = "/getReformAttInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改落实或整改评价获取所属的附件")
    public JsonBean getReformAttInfo(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="reformid",value="整改方案主键 ",required=true)@RequestParam(value = "reformid", required = true) Integer reformid) {
    	JsonBean jsonBean = null;
		try {
			jsonBean = this.refopmservice.getAttListByReformId(token,reformid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    @RequestMapping(value = "/delRefromAttInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "整改落实或评价删除选择的附件")
    public JsonBean delRefromAttInfo(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
    		@ApiParam(name="attid",value="附件ID ",required=true)@RequestParam(value = "attid", required = true)  BigDecimal attid) {
    	JsonBean jsonBean = null;
		try {
			jsonBean = this.refopmservice.delAttListByReformId(token,attid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
    }
    
    @RequestMapping(value = "/pjthReformInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改评价-退回信息")
   	public JsonBean pjthReformInfo(
   			 @ApiParam(name="reformid",value="任务id",required=false)   BigDecimal reformid,
   			 @ApiParam(name="refopm",value="整改评价实体",required=true)TblNbsjRefopm refopm,
   			 @ApiParam(name="solutionid",value="方案id",required=false)   BigDecimal solutionid,
   			@ApiParam(name="attids",value="上传附件id拼接串",required=false)  String attids,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			if(reformid!=null) {
   				refopm.setReformid(reformid);
   			}
   			jsonBean=refopmservice.update(refopm, token, solutionid, attids, "2");
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    @RequestMapping(value = "/tjpjReform", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
   	@ApiOperation(value = "整改评价-提交评价信息")
   	public JsonBean tjpjReform(
   			 @ApiParam(name="solutionid",value="方案id",required=false)   BigDecimal solutionid,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			jsonBean=refopmservice.pjtjyz(solutionid, token);
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
   	
    
    @GetMapping("/getwxhContentsList")
    @ApiOperation("未销号问题列表分页功能")
    public JsonBean getwxhContentsList(HttpServletRequest request,
    		@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		@ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
   		@ApiParam(name="code",value="问题编号",required=false)@RequestParam(value = "code", required = false) String code) {
    	JsonBean jsonBean = null;
    	try {
    		TblNbsjRefopm re =new TblNbsjRefopm();
    		re.setCode(code);
			jsonBean = refopmservice.getAllReformNbsjBywxh(re,  pageNumber, pageSize);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
        return jsonBean;
    }
    
    
    @RequestMapping(value = "/wxhXfSolutionRy", produces = "application/json; charset=utf-8", method = {RequestMethod.POST})
	@ApiOperation(value = "未销号-再次下发")
	public JsonBean wxhXfSolutionRy(
			 @ApiParam(name="reformid",value="分派任务id",required=false)  BigDecimal reformid,
			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
    	JsonBean jsonBean = null;
		try {
			TblNbsjRefopm re =new TblNbsjRefopm();
			if(reformid!=null) {
				re.setReformid(reformid);
			}
			jsonBean=refopmservice.saveOrupdate(re,token,null);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
	} 
    
    
    @GetMapping(value = "/getzgjgReformlist")
	@ApiOperation(value = "整改查询-根据整改内容查询结果集合")
	public JsonBean getzgjgReformlist(
			 @ApiParam(name="problemid",value="整改内容id",required=false) @RequestParam(value="problemid", required = false) String problemid,
			 @ApiParam(name="soultionid",value="方案id",required=false) @RequestParam(value="soultionid", required = false) BigDecimal soultionid,
			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
    	JsonBean jsonBean = null;
		try {
			
			jsonBean=refopmservice.getResultall(soultionid, token, problemid);
		} catch (Exception e) {
			e.printStackTrace();
			ResponseFormat.retParam(0,1000,e.getMessage());
		}
		return jsonBean;
	} 
    
    
    
    @GetMapping(value = "/getzgjgReformByid")
   	@ApiOperation(value = "获取问题整改结果信息")
   	public JsonBean getzgjgReformByid(
   			 @ApiParam(name="reformid",value="任务id",required=false) @RequestParam(value="reformid", required = false) String reformid,
   			 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
       	JsonBean jsonBean = null;
   		try {
   			jsonBean = refopmservice.getByid(reformid);
   		} catch (Exception e) {
   			ResponseFormat.retParam(0,1000,e.getMessage());
   		}
   		return jsonBean;
   	} 
    
    
    /**
               * 整改查询-导出
     *
     * @param request
     * @return
     */
	@RequestMapping(value = "/zgcx/exploredInfo",method = {RequestMethod.POST}, produces = "application/html; charset=utf-8")
	@ApiOperation(value = "整改查询导出")
	public void  contract_contractLedgerList(HttpServletRequest request, HttpServletResponse response,
	@ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token") String token,
	@ApiParam(name="solutionid",value="方案id",required=false)@RequestParam(value="soultionid", required = false)   BigDecimal solutionid) {
		try {
			List<Object[]> list = solutionService.findAlls2(solutionid);
			String[] cNames = {"审计类别","项目名称","被审计单位","业务单元","审计发现","审计建议","整改措施","整改落实情况","整改结论","整改责任人","责任部门","整改期限","整改状态"};
			ExcelUtil exportUtil = new ExcelUtil("整改结果", cNames);
			HSSFCell cell = null;
			HSSFCellStyle bodyStyle = exportUtil.getBodyStyle();
			if (list != null && list.size() > 0) {
				for (int j = 0; j < list.size(); j++) {
					Object[] obj = list.get(j);
					HSSFRow bodyRow = exportUtil.getNextRow(j + 1);
					
					cell = bodyRow.createCell(0);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[11]!=null?obj[11].toString():"");
					
					cell = bodyRow.createCell(1);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[0]!=null?obj[0].toString():"");
					
					
					
					cell = bodyRow.createCell(2);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[1]!=null?obj[1].toString():"");
					
					
					cell = bodyRow.createCell(3);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[2]!=null?obj[2].toString():"");
					
					
					cell = bodyRow.createCell(4);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[4]!=null?obj[4].toString():"");
					
					
					cell = bodyRow.createCell(5);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[13]!=null?obj[13].toString():"");
					
					cell = bodyRow.createCell(6);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[5]!=null?obj[5].toString():"");
					
					
					cell = bodyRow.createCell(7);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[6]!=null?obj[6].toString():"");
					
					
					
					cell = bodyRow.createCell(8);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[7]!=null?obj[7].toString():"");
					
					cell = bodyRow.createCell(9);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[9]!=null?obj[9].toString():"");
					
					cell = bodyRow.createCell(10);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[14]!=null?obj[14].toString():"");
					
					cell = bodyRow.createCell(11);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[15]!=null?obj[15].toString():"");
					
					cell = bodyRow.createCell(12);
					cell.setCellStyle(bodyStyle);
					cell.setCellValue(obj[16]!=null?obj[16].toString():"");
					
		           }
			}
			exportUtil.writeOut(response, "整改结果.xls");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	
	
	 @GetMapping(value = "/getzlAllReformlist")
		@ApiOperation(value = "整改台账-分页列表")
		public JsonBean getzlAllReformlist(
				 @ApiParam(name="auditorg",value="公司id(查询条件)",required=false) @RequestParam(value="auditorg", required = false) BigDecimal auditorg,
				 @ApiParam(name="code",value="问题编号",required=false) @RequestParam(value="code", required = false) String code,
				 @ApiParam(name="projectname",value="项目名称",required=false) @RequestParam(value="projectname", required = false) String projectname,
				 @ApiParam(name="pageNumber",value="分页当前页数",required=false)@RequestParam(value = "pageNumber", required = false, defaultValue = "1") Integer pageNumber,
			   		@ApiParam(name="pageSize",value="每页记录数",required=false)@RequestParam(value = "pageSize", required = false, defaultValue = "15") Integer pageSize,
				 @ApiParam(name="token",value="登录用户token",required=false) @RequestHeader("token")String token)throws Exception{
	    	JsonBean jsonBean = null;
			try {
				
				jsonBean=refopmservice.selectNbsjReformByAll(auditorg, code, projectname, pageNumber, pageSize, token);
			} catch (Exception e) {
				e.printStackTrace();
				ResponseFormat.retParam(0,1000,e.getMessage());
			}
			return jsonBean;
		} 
    
    
    
    
}
